import reqests from "../utils/requests.js"
import {STATUS_CODE} from "../utils/variables.js"


/**
 * 发表评论
 * @param {Object} data
 */
export async function  sendComment(data){
	const res = await reqests.request({
		url: "/user/comment",
		data,
		method: "POST"
	})
	if(res.code!=STATUS_CODE.SUCCESS_CODE){
		uni.showToast({
			title:"出错了，请稍后重试",
			icon:'none',
			duration:2000
		})
		return;
	}
	return res.code;
}

/**
 * 获取评论
 * @param {Object} data
 */
export async function  getCommentApi(data){
	const res = await reqests.request({
		url: "/comment",
		data,
		method: "PUT"
	})
	if(res.code!=STATUS_CODE.SUCCESS_CODE){
		uni.showToast({
			title:"出错了，请稍后重试",
			icon:'none',
			duration:2000
		})
		return;
	}
	return res.data;
}